package com.ls.controller.holiday;

import cn.dev33.satoken.stp.StpUtil;
import com.ls.controller.holiday.model.AddHolidayModel;
import com.ls.controller.holiday.model.EditHolidayModel;
import com.ls.controller.holiday.model.QueryHolidayModel;
import com.ls.controller.holidaycategory.model.AddCategoryModel;
import com.ls.controller.holidaycategory.model.EditCategoryModel;
import com.ls.service.IHolidayService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName HolidayAppController
 * @Description app节假日
 *
 * @author pengyu
 * @since 2024-06-28
 */
@Api(value = "app节假日", tags = "app节假日")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/holidayApp")
public class HolidayAppController {
    private final IHolidayService service;

    /** 新增节假日  */
    @PostMapping("add")
    public ResultData add(@Valid @RequestBody AddHolidayModel model) {
        Long customerId = StpUtil.getLoginIdAsLong();
        model.setCustomerId(customerId);
        return service.add(model);
    }
    /** 更新节假日  */
    @PostMapping("edit")
    public ResultData edit(@Valid @RequestBody EditHolidayModel model) {
        Long customerId = StpUtil.getLoginIdAsLong();
        model.setCustomerId(customerId);
        return service.edit(model);
    }
    /**查询节日是否能直接删除或者编辑 type为0删除，1为编辑*/
    @GetMapping("getHolidayStatus")
    public ResultData getHolidayStatus(@RequestParam Long holidayId,Integer type) {
        return service.getHolidayStatus(holidayId,type);
    }

    /** 删除节假日 */
    @PostMapping("del")
    public ResultData del(@RequestParam Long holidayId) {
        return service.del(holidayId);
    }

    /** 查询节假日列表 */
    @GetMapping("getPaging")
    public ResultData getHoliday(Long categoryId) {
        return service.getAppHoliday(categoryId);
    }

    /** 查询节假日详情 */
    @GetMapping("getDetail")
    public ResultData getDetail(@RequestParam Long holidayId) {
        return service.getDetail(holidayId);
    }
    /**查询节日动态  全部为null,系统节日1，生日2，其他分类传入3*/
    @GetMapping("getHolidayDynamic")
    public ResultData getHolidayDynamic(QueryHolidayModel model) {
        return service.getHolidayDynamic(model);
    }
    /**查询未设置生日的数量*/
    @GetMapping("getNotSetBirthdayCount")
    public ResultData getNotSetBirthdayCount() {
        return service.getNotSetBirthdayCount();
    }
    /**查询当月节日数量*/
    @GetMapping("getHolidayCount")
    public ResultData getHolidayCount() {
        return service.getHolidayCount();
    }
}
